package com.buba.MyInterceptor;

import com.buba.customer.pojo.CustomerLogin;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * 自定义拦截器
 * 实现springMVC提供的
 */
public class MyInterceptor implements HandlerInterceptor {
//    @Override
//    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
//       //获取已经登陆的用户对象
//        HttpSession session = request.getSession();
//        CustomerLogin customerLogin = (CustomerLogin) session.getAttribute("customerLogin");
//        System.out.println("当前登陆的对象"+ customerLogin);
//        //如果当前登陆对象是空，则跳转到登陆页面进行登陆操作
//        if(customerLogin == null)
//            //重定向到登录页面
//            response.sendRedirect("/login.jsp");
//        //返回true继续执行
//        return true;
//    }
}
